package qlsl.androiddesign.activity.subactivity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import android.os.Bundle;
import qlsl.androiddesign.activity.baseactivity.BaseActivity;
import qlsl.androiddesign.entity.commonentity.Pager;
import qlsl.androiddesign.entity.otherentity.CarModel;
import qlsl.androiddesign.util.commonutil.PagerUtils;
import qlsl.androiddesign.view.baseview.FunctionView;
import qlsl.androiddesign.view.subview.activityview.ModelView;

public class ModelActivity extends BaseActivity {

	private ModelView functionView;

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		functionView = new ModelView(this);
	}

	public FunctionView<?> getFunctionView() {
		return functionView;
	}

	public void onNetWorkSucceed(String method, Object values) {
		if (method.equals("queryModelList")) {
			functionView.showData(values);
		}
	}

	public void onOtherSucceed(String method, Object values) {
		if (method.equals("queryModelList")) {
			HashMap<String, Object> map = new HashMap<String, Object>();
			List<CarModel> list = new ArrayList<CarModel>();
			Pager pager = PagerUtils.createPager(1, 999);
			map.put("list", list);
			map.put("pager", pager);
			if (list.size() == 0) {
				for (int index = 0; index < 50; index++) {
					CarModel item = new CarModel();
					item.setName("型号" + (index + 1));
					list.add(item);
				}
			}
			functionView.showData(map);
		}
	}

}
